﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;

namespace TransportAbstractionLibrary.Common.BufferPool
{
    internal sealed class BufferLink
    {
        WeakReference owner;
        int index;
        BufferInstance parent;
        int bufferSize;

        internal int Index
        {
            get
            {
                return index;
            }
        }


        internal BufferLink(int index, BufferInstance parent, int bufferSize)
        {
            this.index = index;
            this.parent = parent;
            this.bufferSize = bufferSize;
            this.owner = new WeakReference(null);
        }

        internal SocketEventArgs Value
        {
            get
            {
                return (SocketEventArgs)owner.Target;
            }
            set
            {
                owner = new WeakReference(value);
            }
        }
    }
}
